<template>
  <div class="student">
    <h2>学生姓名:{{name}}</h2>
    <h2>学生年龄:{{age}}</h2>
    <button @click="sendStudentName">点我把学校名给App</button>
    <button @click="xcc2">点我触发xcc2</button>
    <button @click="unbindXcc">点我解绑xcc事件</button>
    <button @click="unbindAll">点我解绑所有事件</button>
    <button @click="death">销毁当前实例(vc)</button>
  </div>
</template>

<script>
export default {
  name: "Student",
  data(){
    return{
      name:'xccit',
      age:21
    }
  },
  methods:{
    sendStudentName(){
      this.$emit('xcc',this.name,666,777,888)
    },
    xcc2(){
      this.$emit('xcc2')
    },
    unbindXcc(){
      this.$off('xcc')
    },
    unbindAll(){
      this.$off(['xcc','xcc2']) //传入一个数组，数组内写所有需要解绑的事件名
      // this.$off() //直接解绑所有事件
    },
    death(){
      this.$destroy()
    }
  }
}
</script>

<style scoped>
  .student{
    background-color: pink;
    padding: 5px;
    margin-top: 30px;
  }
</style>